﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="EditBookDetails.aspx.vb" Inherits="BooksReviewApp.EditBookDetails" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
    <div class="Picture">
        <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
                <h2>
                    <%# Eval("BookName") %></h2>
            </ItemTemplate>
        </asp:Repeater>
        <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
                <asp:HyperLink ID="Hl_Category" runat="server" Text='<%# Eval("Category")%>' NavigateUrl='<%# Eval("Category", "BooksByCategory.aspx?Category={0}")%>'
                    ForeColor="#009999" Font-Bold="False" Font-Size="Small">
                </asp:HyperLink>
                •
                <asp:HyperLink ID="Hl_SubCategory" runat="server" Text='<%# Eval("SubCategory")%>' NavigateUrl='<%# Eval("SubCategory", "BooksBySubCategory.aspx?SubCategory={0}")%>'
                    ForeColor="Orange" Font-Bold="False" Font-Size="Small">
                </asp:HyperLink>
                <br />
                &nbsp;By •
                <asp:HyperLink ID="HyperLink2" runat="server" Text='<%# Eval("Bibliophile")%>' NavigateUrl='<%# Eval("Bibliophile", "Profile.aspx?Bibliophile={0}")%>'
                    ForeColor="Red" Font-Bold="True" CssClass="red" Font-Size="Smaller">
                </asp:HyperLink>
                <br />
            </ItemTemplate>
        </asp:Repeater>
        <asp:Repeater ID="Repeater3" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
                <asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl='<%# String.Format("https://www.bookdepository.com/search?searchTerm={0}", Eval("BookName"))%>'>
                <img src='../<%# Eval("Picture") %>' alt="No Picture" width="210" height="280" />
                </asp:HyperLink>
            </ItemTemplate>
        </asp:Repeater>
        <br />
        <asp:Repeater ID="Repeater4" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
            Posted • 
                <asp:Label ID="lbl_Time" runat="server" Text='<%# CalculateTime.calculateTime(Eval("DateAdded")) %>'
                    ForeColor="#009999" />
            </ItemTemplate>
        </asp:Repeater>
        
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
                <span class="FavoriteButton">
                    <br />
                    <asp:Button ID="btn_Update" runat="server" Text="Update Details" CssClass="m-btn blue" /><br />
                    </span>
                <span class="DeleteButton">
                    <br />
                    
                    <asp:Button ID="btn_Delete" runat="server" Text="Delete" CssClass="m-btn red" OnClientClick="return confirm('Are you sure you want to delete this Book Review?');"/>
                </span>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
     <div class="BasicInformation">
        <br />
        <br />
        <h3>
            Description</h3>
        <br />
        <br />
        <div id="Description">
            <asp:TextBox ID="tb_Description" runat="server" TextMode="MultiLine" Width="370" MaxLength="300" Rows="6"></asp:TextBox>
        </div>
        <h3>
            Review</h3>
        <br />
        <br />
        <div id="Review">
            <asp:TextBox ID="tb_Reviews" runat="server" TextMode="MultiLine" Width="370" MaxLength="300" Rows="6"></asp:TextBox>
             <br />
            <br /> <br />
            <br />
        </div>
    </div>
    <div class="Ratings">
            <br />
            <br />
        <h3>Title</h3>
        <br />
         <br />
         <asp:TextBox ID="tb_BookName" runat="server" TextMode="SingleLine"></asp:TextBox>
        <br />
        <h3>Language</h3>
        <br />
         <br />
        <asp:DropDownList ID="ddl_Language" runat="server" DataSourceID="SqlDataSource3" DataTextField="Language" DataValueField="ID" AppendDataBoundItems="True">
                    <asp:ListItem Value="0">Choose a Language</asp:ListItem>
                    </asp:DropDownList>
        
        
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:BooksReviewDBConnectionString1 %>" SelectCommand="SELECT * FROM [CodingLanguages]"></asp:SqlDataSource>
        <br />
        <br />
        
        <h3>Rating</h3>
            <br />
            <br />
            <asp:Label ID="Label2" CssClass="RatingNameLabel1" runat="server" Text="Your Rating" />
                <asp:Repeater ID="Repeater8" runat="server" DataSourceID="SqlDataSource6" Visible="false">
                    <ItemTemplate>
                        <div class="ImageRating">
                            <img src='<%# getRating(Eval("UserRating")) %>' alt="No picture found" width="120"
                                height="30" /></div>
                    </ItemTemplate>
                </asp:Repeater>
                <asp:Button ID="btn_Change" runat="server" Text="Change your Rating!" CssClass="m-btn blue"
                    Visible="false" />
                <ajaxToolkit:Rating ID="Rating1" runat="server" EmptyStarCssClass="emptypng" FilledStarCssClass="smileypng"
                    StarCssClass="smileypng" WaitingStarCssClass="donesmileypng" HorizontalAlign="Left">
                </ajaxToolkit:Rating>
                <p>
                    <asp:Button ID="btn_Rating" runat="server" Text="Rate it!" CssClass="m-btn blue" />
                </p>

        <h3>Category</h3>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>        <br />
         <br />
                    <asp:DropDownList ID="ddl_Genre" runat="server" AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="SqlDataSource2" DataTextField="Category" DataValueField="ID">
                        <asp:ListItem Value="0">Change Category</asp:ListItem>
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:BooksReviewDBConnectionString1 %>" SelectCommand="SELECT [ID], [Category] FROM [ComputingCategories]"></asp:SqlDataSource>

        <br />
        <br />
        <asp:DropDownList ID="ddl_SubCategory" runat="server" DataSourceID="SqlDataSource4" DataTextField="SubCategory" DataValueField="ID">
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:BooksReviewDBConnectionString1 %>" SelectCommand="SELECT [ID], [SubCategory] FROM [ComputingSubCategories] WHERE ([Category_FK] = @Category_FK)">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="ddl_Genre" Name="Category_FK" PropertyName="SelectedValue" Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>
        <br/>
        <br />
                </ContentTemplate>

            </asp:UpdatePanel>
    </div>


    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BooksReviewDBConnectionString1 %>" SelectCommand="SELECT * FROM [Books_Categories_View] WHERE ([ID] = @ID)">
        <SelectParameters>
            <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:BooksReviewDBConnectionString1 %>"
                    ProviderName="<%$ ConnectionStrings:BooksReviewDBConnectionString1.ProviderName %>" SelectCommand="SELECT * FROM [BookAverageRating] WHERE ([Book_FK] = @Book_FK)">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="Book_FK" QueryStringField="ID" Type="Int32" />
                    </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSource6" runat="server" ConnectionString="<%$ ConnectionStrings:BooksReviewDBConnectionString1 %>"
                    ProviderName="<%$ ConnectionStrings:BooksReviewDBConnectionString1.ProviderName %>" SelectCommand="SELECT * FROM [BookUserRating] WHERE ([Book_FK] = @Book_FK) AND ([Bibliophile] = @Bibliophile)">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="Book_FK" QueryStringField="ID" Type="Int32" />
                        <asp:Parameter Name="Bibliophile" Type="String" />
                    </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
